package com.example.company.service.impl;


import com.example.company.entity.Leaves;
import com.example.company.entity.Positions;
import com.example.company.mapper.LeavesMapper;
import com.example.company.service.ILeavesService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 存储员工请假信息Service业务层处理
 *
 * @author ruoyi
 * @date 2024-12-30
 */
@Service
public class LeavesServiceImpl implements ILeavesService {
	@Autowired
	private LeavesMapper leavesMapper;
	
	/**
	 * 查询存储员工请假信息
	 *
	 * @param LeaveID 存储员工请假信息主键
	 * @return 存储员工请假信息
	 */
	@Override
	public Leaves selectLeavesByLeaveID(Long LeaveID) {
		return leavesMapper.selectLeavesByLeaveID(LeaveID);
	}
	
	/**
	 * 查询存储员工请假信息列表
	 *
	 * @param leaves 存储员工请假信息
	 * @return 存储员工请假信息
	 */
	@Override
	public List<Leaves> selectLeavesList(Leaves leaves) {
		return leavesMapper.selectLeavesList(leaves);
	}
	
	/**
	 * 新增存储员工请假信息
	 *
	 * @param leaves 存储员工请假信息
	 * @return 结果
	 */
	@Override
	public int insertLeaves(Leaves leaves) {
		return leavesMapper.insertLeaves(leaves);
	}
	
	/**
	 * 修改存储员工请假信息
	 *
	 * @param leaves 存储员工请假信息
	 * @return 结果
	 */
	@Override
	public int updateLeaves(Leaves leaves) {
		return leavesMapper.updateLeaves(leaves);
	}
	
	/**
	 * 批量删除存储员工请假信息
	 *
	 * @param LeaveIDs 需要删除的存储员工请假信息主键
	 * @return 结果
	 */
	@Override
	public int deleteLeavesByLeaveIDs(Long[] LeaveIDs) {
		return leavesMapper.deleteLeavesByLeaveIDs(LeaveIDs);
	}
	
	/**
	 * 删除存储员工请假信息信息
	 *
	 * @param LeaveID 存储员工请假信息主键
	 * @return 结果
	 */
	@Override
	public int deleteLeavesByLeaveID(Long LeaveID) {
		return leavesMapper.deleteLeavesByLeaveID(LeaveID);
	}
	
	@Override
	public PageInfo<Leaves> findPage(Integer pageNum, Integer pageSize, Leaves leaves) {
		PageHelper.startPage(pageNum, pageSize);
		List<Leaves> list =leavesMapper.selectLeavesList(leaves);
		
		System.out.println("List size: " + list.size());
		System.out.println("Page size: " + pageSize);
		PageInfo<Leaves> info = new PageInfo<>(list);
		return info;
	}
	
}
